
//
//  DetailController.m
//  JZRJAPPT
//
//  Created by mac on 16/5/10.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "DetailController.h"
#import "HomeController.h"
#import "NetWorkManager.h"
#import "LiuXSegmentView.h"
#import "LastCollectionCell.h"
#import "MessageViewCell.h"
#import "LineChartView.h"
#import "DateTransform.h"

#import "SeachViewController.h"
#import "IncomeModel.h"
#import "DayRankModel.h"
#import "TechZBListModel.h"
#import "JBMZBListModel.h"
#import "FundListModel.h"
#import "NewListModel.h"
#import "TradeStockModel.h"

#import "UIColor+helper.h"

#import "EverChart.h"
#import "YKLineChart.h"
#import "CommentController.h"
#import "ChartView.h"

#define MA5 5
#define MA10 10
#define MA20 20
@interface DetailController ()<UIScrollViewDelegate,CPSpinnerButtonViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITableViewDelegate,UITableViewDataSource,YKLineChartViewDelegate>



@property (nonatomic ,strong) YKLineChartView *klineView;



@property (nonatomic ,strong) UIView *navView;
@property (nonatomic ,strong) UIButton *leftBtn;
@property (nonatomic ,strong) UIButton *goBtn;
@property (nonatomic ,strong) UIButton *backBtn;
@property (nonatomic ,strong) UILabel * nameLabel;
@property (nonatomic ,strong) UIButton *rightBtn;

@property (nonatomic ,strong) UIScrollView *scrollView;

@property (nonatomic ,strong) UIView *headView;

@property (nonatomic ,strong)  CPSpinnerButtonView * FKView;
/**
 *  最顶上显示的Label的数据
 */

@property (nonatomic ,strong)UILabel *label1;
@property (nonatomic ,strong)UILabel *label2;
@property (nonatomic ,strong)UILabel *label3;
@property (nonatomic ,strong)UILabel *label4;
@property (nonatomic ,strong)UILabel *label5;
@property (nonatomic ,strong)UILabel *label6;
@property (nonatomic ,strong)UILabel *label7;
@property (nonatomic ,strong)UILabel *label8;
@property (nonatomic ,strong)UILabel *label9;
@property (nonatomic ,strong)UILabel *label10;
@property (nonatomic ,strong)UILabel *label11;
@property (nonatomic ,strong)UILabel *label12;
@property (nonatomic ,strong)UILabel *label13;
@property (nonatomic ,strong)UILabel *label14;
@property (nonatomic ,strong)UILabel *label15;
//卖一  卖一量
@property (nonatomic ,strong) UILabel * sell51;
@property (nonatomic ,strong) UILabel * sell52;

@property (nonatomic ,strong) UILabel * sell41;
@property (nonatomic ,strong) UILabel * sell42;

@property (nonatomic ,strong) UILabel * sell31;
@property (nonatomic ,strong) UILabel * sell32;

@property (nonatomic ,strong) UILabel * sell21;
@property (nonatomic ,strong) UILabel * sell22;

@property (nonatomic ,strong) UILabel * sell11;
@property (nonatomic ,strong) UILabel * sell12;


// 买一 买一量

@property (nonatomic ,strong) UILabel * buy51;
@property (nonatomic ,strong) UILabel * buy52;


@property (nonatomic ,strong) UILabel * buy41;
@property (nonatomic ,strong) UILabel * buy42;

@property (nonatomic ,strong) UILabel * buy31;
@property (nonatomic ,strong) UILabel * buy32;

@property (nonatomic ,strong) UILabel * buy21;
@property (nonatomic ,strong) UILabel * buy22;

@property (nonatomic ,strong) UILabel * buy11;
@property (nonatomic ,strong) UILabel * buy12;






@property (nonatomic ,strong) UILabel *dataLabel;
@property (nonatomic ,strong) UILabel *liangLabel;
@property (nonatomic ,strong) UILabel *jianyiLabel;

@property (nonatomic ,strong) UIView *FenKview;
@property (nonatomic ,strong) UIView *Fenview;

@property (nonatomic ,strong) UIView *FenBorromView;

@property (nonatomic ,strong)UIView * ZXView;

@property (nonatomic ,strong)LiuXSegmentView *TopView;


@property (nonatomic ,strong)LiuXSegmentView *LastView;

@property (nonatomic ,strong) UIView *view2;

@property (nonatomic ,strong) LineChartView *lineChartView;

@property (nonatomic ,strong) NSMutableArray *dataArray;

@property (nonatomic ,strong) UICollectionView *collectionView;

@property (nonatomic ,strong) UITableView *tableView;

@property (nonatomic ,strong) IncomeModel *incomeModel;

@property (nonatomic ,strong) DayRankModel *rankModel;

@property (nonatomic ,strong) NSString *codeStr;



@property (nonatomic ,strong) UIView *rightView;

@property (nonatomic) PNBarChart * barChart;
// 柱状图
@property (nonatomic, strong) ChartView *chartView;

// 技术面数据数组
@property (nonatomic ,strong) NSMutableArray *techArray;

// 消息数组
@property (nonatomic ,strong) NSMutableArray *messageArray;

//资金数组
@property (nonatomic ,strong) NSMutableArray *amountArray;
@property (nonatomic ,strong) NSMutableArray *amountDateArray;

// 量化收益曲线字典
@property (nonatomic ,strong) NSMutableDictionary *inComeRateDic;
@property (nonatomic ,strong) NSMutableDictionary *DapanIncomeRateDic;
@property (nonatomic ,strong) NSMutableArray *dateArray;


 /**
 *  最底部的view
 */
@property(nonatomic,strong) UIView *bottomView;

// 分时线
@property (strong, nonatomic) EverChart *fenshiChart;
@end

@implementation DetailController

static  NSString *cellindefiler = @"collectioncell";
static  NSString *cellfile = @"tabCell";


#pragma mark  懒加载
-(NSMutableArray *)techArray{
    
    if (!_techArray) {
        _techArray =[NSMutableArray array];
    }
    return _techArray;
}

-(NSMutableArray *)messageArray{
    if (!_messageArray) {
        _messageArray =[NSMutableArray array];
    }
    return _messageArray;
}

-(NSMutableDictionary *)inComeRateDic{
    if (!_inComeRateDic) {
        _inComeRateDic =[NSMutableDictionary dictionary];
    }
    return _inComeRateDic;
}

-(NSMutableDictionary *)DapanIncomeRateDic{
    if (!_DapanIncomeRateDic) {
        _DapanIncomeRateDic =[NSMutableDictionary dictionary];
    }
    return _DapanIncomeRateDic;
    
}
-(NSMutableArray *)amountArray{
    if (!_amountArray) {
        _amountArray = [NSMutableArray array];
    }
    return _amountArray;
}
-(NSMutableArray *)amountDateArray{
    if (!_amountDateArray) {
        _amountDateArray =[NSMutableArray array];
    }
    return  _amountDateArray;
}
-(void)dataNameLabel{
  
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 2 -50, 30, 100, 30)];
    
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.textColor = [UIColor whiteColor];
    
    
    if (self.incomeArray != nil) {
        _incomeModel = self.incomeArray[_index];
        _nameLabel.text = _incomeModel.Name;
        _codeStr = _incomeModel.Code;
    }
    if (self.rankArray !=nil) {
        _rankModel = self.rankArray[_index];
        _nameLabel.text = _rankModel.Name;
        _codeStr = _rankModel.Code;
        
    }
}



#pragma  mark 技术面 基础面 ，资金 消息的数据解析
/**
 *  技术面
 */
-(void)dataGetStockQuantifyData{
    NSString *str1 =[GetStockQuantifyData stringByAppendingString:_codeStr];
    [NetWorkManager getUrl:str1 paramdic:nil success:^(id data) {
        NSMutableArray *dataArray = [NSMutableArray array];
        NSMutableArray *array = [data[@"TechZBList"] mutableCopy];
        for (NSDictionary *dic in array) {
        TechZBListModel *tecModel = [TechZBListModel new];
        [tecModel setValuesForKeysWithDictionary:dic];
        [dataArray addObject:tecModel];
    }
    self.techArray = dataArray;
    [self.collectionView reloadData];
       
} error:^(id error) {
        NSLog(@"%@",error);
    }];
}

/**
 *  基础面
 */
-(void)dataGetStockQuantifyData1{
    NSString *str1 =[GetStockQuantifyData stringByAppendingString:_codeStr];
    [NetWorkManager getUrl:str1 paramdic:nil success:^(id data) {
        NSMutableArray *dataArray = [NSMutableArray array];
        NSMutableArray *array = [data[@"JBMZBList"] mutableCopy];
        for (NSDictionary *dic in array) {
            JBMZBListModel *jbModel = [JBMZBListModel new];
            [jbModel setValuesForKeysWithDictionary:dic];
            [dataArray addObject:jbModel];
        }
        self.techArray = dataArray;
        [self.collectionView reloadData];
        
    } error:^(id error) {
        NSLog(@"%@",error);
    }];
}
/**
 *  资金
 */

-(void)dataGetStockQuantifyData2{
    NSString *str1 =[GetStockQuantifyData stringByAppendingString:_codeStr];
    [NetWorkManager getUrl:str1 paramdic:nil success:^(id data) {
        NSMutableArray *amountArray = [NSMutableArray array];
        NSMutableArray *dateArray = [NSMutableArray array];
        NSMutableArray *array = [data[@"FundList"] mutableCopy];
        for (NSDictionary *dic in array) {
            
            NSString *amountStr =dic[@"Amount"];
            
            NSString *dateStr = [NSString stringWithFormat:@"%@",dic[@"Date"]];
            
            NSString *str  = [dateStr substringWithRange:NSMakeRange(6, 10)];
            NSString *str2 = [DateTransform dateTransformTodate1:str];
            NSLog(@"%@",str);
            NSLog(@"日期格式%@",str2);
            
        
            [amountArray addObject:amountStr];
            [dateArray addObject:str2];
            
        }
        self.amountArray = amountArray.mutableCopy;
        self.amountDateArray = dateArray.mutableCopy;
        
        UILabel *ziJinLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 300, 30)];
        
        ziJinLabel.font = [UIFont systemFontOfSize:15];
        NSNumber *sum = [self.amountArray valueForKeyPath:@"@sum.floatValue"];
        ziJinLabel.text = [NSString stringWithFormat:@"当前资金流入%@万元",sum];
        
        [_view2 addSubview:ziJinLabel];
        
       // [self.barChart setXLabels:self.amountDateArray];
       // [self.barChart setYValues:self.amountArray];
        
//        _chartView.yields = self.amountArray;
//        _chartView.dayPoints = self.amountDateArray;
        [_chartView refreshChartWithYields:self.amountArray dayPoints:self.amountDateArray];
        
    } error:^(id error) {
        NSLog(@"%@",error);
    }];
}

/**
 *  消息
 */

-(void)dataGetStockQuantifyData3{
    NSString *str1 =[GetStockQuantifyData stringByAppendingString:_codeStr];
    [NetWorkManager getUrl:str1 paramdic:nil success:^(id data) {
        NSMutableArray *dataArray = [NSMutableArray array];
        NSMutableArray *array = [data[@"NewsList"] mutableCopy];
        for (NSDictionary *dic in array) {
            NewListModel *newModel = [NewListModel new];
            [newModel setValuesForKeysWithDictionary:dic];
            [dataArray addObject:newModel];
        }
        self.messageArray = dataArray;
        [self.tableView reloadData];
        //NSLog(@"asdaasdas%@",self.messageArray);
        
    } error:^(id error) {
        NSLog(@"%@",error);
    }];
}
/**
 *  量化收益曲线图
 */
-(void)getDataStockTrade{
    NSString *str1 = [GetStockTradeData stringByAppendingString:_codeStr];
    [NetWorkManager getUrl:str1 paramdic:nil success:^(id data) {

        NSMutableDictionary *dict  = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict1 = [NSMutableDictionary dictionary];
        NSMutableArray *array =[NSMutableArray array];
        for (NSDictionary *dic in data) {
            NSString *str = dic[@"IncomeRate"];
            NSString *str1 = dic[@"DapanIncomeRate"];
            NSString *dateStr = [DateTransform dateTransformTodate:dic[@"DateStamp"]];
            [array addObject:dateStr];
           [dict setObject: str forKey:dateStr];
            [dict1 setObject:str1 forKey:dateStr];
        }
        self.inComeRateDic = [NSMutableDictionary dictionaryWithDictionary:dict];
        self.DapanIncomeRateDic =[NSMutableDictionary dictionaryWithDictionary:dict1];
        self.dateArray = [NSMutableArray arrayWithArray:array];
        self.lineChartView =[[LineChartView alloc]initWithFrame:CGRectMake(5, 10, SCREEN_WIDTH -10, 240)];
       // [self getDataStockTrade];
       
        // 显示日期的两个label
        UILabel *startLabel =[[UILabel alloc]initWithFrame:CGRectMake(20, 255, 70, 20)];
        startLabel.text = self.dateArray[0];
        startLabel.font =[UIFont systemFontOfSize:12];
        UILabel *endLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH- 70, 255, 70, 20)];
        endLabel.text = self.dateArray.lastObject;
        endLabel.font =[UIFont systemFontOfSize:12];
        
        [_ZXView addSubview:startLabel];
        [_ZXView addSubview:endLabel];
        
        _lineChartView.backgroundColor = [UIColor whiteColor];
         [self zhexianfuzhi];
        
        [_ZXView addSubview:_lineChartView];
     //   NSLog(@"组装好的字典%@",_inComeRateDic);
      //  NSLog(@"%@",_DapanIncomeRateDic);
    } error:^(id error) {
        NSLog(@"%@",error);
    }];
}

-(void)zhexianfuzhi{
     _lineChartView.dataDictionary = self.inComeRateDic;
    _lineChartView.data1Dictionary = self.DapanIncomeRateDic;
     _lineChartView.dateDetailArray = self.dateArray;
    

}

#pragma  mark 拼接字符串
-(NSString *)stringDo:(NSString *)str{
    NSString *str1 = [str stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSString *str2 = [str1 substringFromIndex:6];
    NSString * str3 = [str2 lowercaseString];
    NSString *str4 = [str3 stringByAppendingString:str1];
    NSString *str5 = [str4 substringToIndex:8];
    NSString *str6 = [GetStockLastData stringByAppendingString:str5];
    NSLog(@"%@",str6);
    return str6;
}
-(void)netData{

    [NetWorkManager getUrl1:[self stringDo:_codeStr] paramdic:nil success:^(id data) {
        
        NSStringEncoding enc =CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
        
        NSString *str = [[NSString alloc] initWithData:data encoding:enc];
        
        NSMutableArray *bigArray = [str componentsSeparatedByString:@";"].mutableCopy;
        [bigArray removeLastObject];
        
        NSMutableArray *nameArray = [NSMutableArray array];
        NSMutableArray *dataArray = [NSMutableArray array];
        for (NSString *s in bigArray) {
            NSString *dataStr = [[s componentsSeparatedByString:@"=\""].lastObject substringToIndex:[s componentsSeparatedByString:@"=\""].lastObject.length - 1];
            [nameArray addObject:[dataStr componentsSeparatedByString:@","].firstObject];
            NSMutableArray *da = [dataStr componentsSeparatedByString:@","].mutableCopy;
            if (da.count > 0) {
                [da removeObjectAtIndex:0];
            }
            [dataArray addObject:da];
        }
        for (int i = 0; i < nameArray.count; i++) {
            NSDictionary *dict = @{
                                   @"name":nameArray[i],
                                   @"values":dataArray[i],
                                   };
            [self.dataArray addObject:dict];
        }
        [self setTopViewFuZhi];
        
//        self.label1.text = self.dataArray[0][@"values"][2];
//        self.label3.text = self.dataArray[0][@"values"][0];
//        self.label11.text = self.dataArray[0][@"values"][1];
//        self.label5.text = self.dataArray[0][@"values"][3];
//        self.label13.text = self.dataArray[0][@"values"][4];
        NSLog(@"%@",self.dataArray);
    
    } error:^(id error) {
        NSLog(@"%@",error);
        
    }];

}
/**
 * 头部视图赋值
 */

-(void)setTopViewFuZhi{
    
    
   
    self.label1.text = self.dataArray[0][@"values"][2];
    
    self.label3.text =[NSString stringWithFormat:@"%.2f",[self.dataArray[0][@"values"][0] floatValue]];
    self.label11.text = [NSString stringWithFormat:@"%.2f",[self.dataArray[0][@"values"][1] floatValue]];
    
    self.label5.text = [NSString stringWithFormat:@"%.2f",[self.dataArray[0][@"values"][3] floatValue]];
    self.label13.text = [NSString stringWithFormat:@"%.2f",[self.dataArray[0][@"values"][4] floatValue]];
    
    self.label8.text = [NSString stringWithFormat:@"%.2f",[self.label1.text floatValue]-[self.label11.text floatValue]];
    if ([self.label8.text floatValue] > 0) {
        self.label8.textColor = [UIColor redColor];
    }else{
        self.label8.textColor = [UIColor greenColor];
    }
    
    self.label9.text = [NSString stringWithFormat:@"%.2f %@",[self.label8.text floatValue]/ [self.label11.text floatValue],@"%"];
    
    if ([self.label9.text floatValue] > 0) {
        self.label9.textColor = [UIColor redColor];
    }else{
        self.label9.textColor = [UIColor greenColor];
    }
    //_zhangLable.text = [NSString stringWithFormat:@"%.2f%@", [dayRankModel.ChgRate floatValue] * 100,@"%"];
    
    float amountStr = [self.dataArray[0][@"values"][7] floatValue];
    
    self.label7.text = [NSString stringWithFormat:@"%.2f",amountStr /3000.00];
    
    self.label15.text =[NSString stringWithFormat:@"%.2f %@",[self.dataArray[0][@"values"][8] floatValue] / 100000000,@"亿"] ;
    
    self.buy11.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][10] floatValue]] ;
    self.buy11.textColor = [UIColor redColor];
    self.buy12.textColor = [UIColor cyanColor];
    self.buy12.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][9] floatValue] / 100] ;
    
    self.buy21.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][12] floatValue]] ;
    self.buy21.textColor = [UIColor redColor];
    self.buy22.textColor = [UIColor cyanColor];
    self.buy22.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][11] floatValue] / 100] ;
    
    self.buy31.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][14] floatValue]] ;
    self.buy31.textColor = [UIColor redColor];
    self.buy32.textColor = [UIColor cyanColor];
    self.buy32.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][13] floatValue] / 100] ;
    
    self.buy41.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][16] floatValue]] ;
    self.buy41.textColor = [UIColor redColor];
    self.buy42.textColor = [UIColor cyanColor];
    self.buy42.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][15] floatValue] / 100] ;
    
    self.buy51.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][18] floatValue]] ;
    self.buy51.textColor = [UIColor redColor];
    self.buy52.textColor = [UIColor cyanColor];
    self.buy52.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][17] floatValue] / 100] ;
    
    
    
    self.sell11.text =[NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][20] floatValue]] ;
    self.sell11.textColor = [UIColor redColor];
    self.sell12.textColor = [UIColor cyanColor];
    self.sell12.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][19] floatValue]] ;
    
    
    self.sell21.text =[NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][22] floatValue]] ;
    self.sell21.textColor = [UIColor redColor];
    self.sell22.textColor = [UIColor cyanColor];
    self.sell22.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][21] floatValue]] ;
    
    
    self.sell31.text =[NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][24] floatValue]] ;
    self.sell31.textColor = [UIColor redColor];
    self.sell32.textColor = [UIColor cyanColor];
    self.sell32.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][23] floatValue]] ;
    
    self.sell41.text =[NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][26] floatValue]] ;
    self.sell41.textColor = [UIColor redColor];
    self.sell42.textColor = [UIColor cyanColor];
    self.sell42.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][25] floatValue]] ;
    
    self.sell51.text =[NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][28] floatValue]] ;
    self.sell51.textColor = [UIColor redColor];
    self.sell52.textColor = [UIColor cyanColor];
    self.sell52.text = [NSString stringWithFormat:@"%.f",[self.dataArray[0][@"values"][27] floatValue]] ;
}

/**
 * 头部视图
 */
-(void)setTopView{
    UILabel *lable1 =[[UILabel alloc]initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH / 4, 30)];
    lable1.text = @"15.7";
    lable1.textAlignment = NSTextAlignmentCenter;
    lable1.textColor = [UIColor redColor];
    self.label1 = lable1;
    
    UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 , 15, SCREEN_WIDTH /10, 20)];
    lable2.text = @"今开";
    //lable2.text = self.dataArray[0][@"values"][0];
    lable2.font =[UIFont systemFontOfSize:14];
    lable2.textAlignment = NSTextAlignmentCenter;
    self.label2 = lable2;
    
    UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 , 15, SCREEN_WIDTH /10, 20)];
    //lable3.text = @"15.66";
    lable3.font =[UIFont systemFontOfSize:12];
    lable3.textAlignment = NSTextAlignmentCenter;
    self.label3 = lable3;
    
    UILabel *lable4 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /5 , 15, SCREEN_WIDTH /10, 20)];
    lable4.text = @"高";
    lable4.font =[UIFont systemFontOfSize:14];
    lable4.textAlignment = NSTextAlignmentCenter;
    self.label4 =lable4;
    
    UILabel *lable5 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *3 , 15, SCREEN_WIDTH /10, 20)];
    lable5.text = @"15.87";
    lable5.font =[UIFont systemFontOfSize:12];
    lable5.textAlignment = NSTextAlignmentCenter;
    self.label5 = lable5;
    
    UILabel *lable6 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *4 , 15, SCREEN_WIDTH /10, 20)];
    lable6.text = @"量";
    lable6.font =[UIFont systemFontOfSize:14];
    lable6.textAlignment = NSTextAlignmentCenter;
    self.label6 = lable6;
    
    
    UILabel *lable7 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *5 , 15, SCREEN_WIDTH /7 , 20)];
    lable7.text = @"15.87万";
    lable7.font =[UIFont systemFontOfSize:12];
    lable7.textAlignment = NSTextAlignmentCenter;
    self.label7 = lable7;
    
    UILabel *lable8 = [[UILabel alloc]initWithFrame:CGRectMake(10 ,40, SCREEN_WIDTH /8 , 20)];
    lable8.text = @"0.19";
    lable8.textColor = [UIColor redColor];
    lable8.font =[UIFont systemFontOfSize:12];
    lable8.textAlignment = NSTextAlignmentCenter;
    self.label8 = lable8;
    
    UILabel *lable9 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /8 ,40, SCREEN_WIDTH /8 , 20)];
    lable9.text = @"1.99%";
    lable9.textColor = [UIColor redColor];
    lable9.font =[UIFont systemFontOfSize:12];
    lable9.textAlignment = NSTextAlignmentCenter;
    self.label9 = lable9;
    
    UILabel *lable10 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 ,40, SCREEN_WIDTH /10 , 20)];
    lable10.text = @"昨收";
    lable10.font =[UIFont systemFontOfSize:14];
    lable10.textAlignment = NSTextAlignmentCenter;
    self.label10 = lable10;
    
    UILabel *lable11 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 , 40, SCREEN_WIDTH /10, 20)];
    lable11.text = @"15.58";
    lable11.font =[UIFont systemFontOfSize:12];
    lable11.textAlignment = NSTextAlignmentCenter;
    self.label11 = lable11;
    
    UILabel *lable12 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /5 , 40, SCREEN_WIDTH /10, 20)];
    lable12.text = @"低";
    lable12.font =[UIFont systemFontOfSize:14];
    lable12.textAlignment = NSTextAlignmentCenter;
    self.label12 = lable12;
    
    UILabel *lable13 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *3 , 40, SCREEN_WIDTH /10, 20)];
    lable13.text = @"15.61";
    lable13.font =[UIFont systemFontOfSize:12];
    lable13.textAlignment = NSTextAlignmentCenter;
    self.label13 = lable13;
    
    UILabel *lable14 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *4 , 40, SCREEN_WIDTH /10, 20)];
    lable14.text = @"额";
    lable14.font =[UIFont systemFontOfSize:14];
    lable14.textAlignment = NSTextAlignmentCenter;
    self.label14 = lable14;
    
    
    UILabel *lable15 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /4 +10 + SCREEN_WIDTH /10 *5 , 40, SCREEN_WIDTH /7 , 20)];
    lable15.text = @"1.7亿";
    lable15.font =[UIFont systemFontOfSize:12];
    lable15.textAlignment = NSTextAlignmentCenter;
    self.label15 = lable15;
    
    [_headView addSubview:lable15];
    [_headView addSubview:lable14];
    [_headView addSubview:lable13];
    [_headView addSubview:lable12];
    [_headView addSubview:lable11];
    
    [_headView addSubview:lable10];
    [_headView addSubview:lable9];
    [_headView addSubview:lable8];
    [_headView addSubview:lable7];
    [_headView addSubview:lable6];
    [_headView addSubview:lable5];
    [_headView addSubview:lable4];
    [_headView addSubview:lable3];
    [_headView addSubview:lable2];
    [_headView addSubview:lable1];
    
    
    
    
}


// 分时图请求数据
-(void)loadDate:(NSString *)url{
    
    AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
    
    sessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
    sessionManager.responseSerializer = [AFJSONResponseSerializer serializer];
    sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/x-javascript", @"text/html",nil];
    // 设置访问超时时间 （系统默认是60）
    sessionManager.requestSerializer.timeoutInterval = 30;
    
    [sessionManager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // NSLog(@"%@",responseObject);
        NSMutableArray *data1 =[[NSMutableArray alloc] init];
        NSMutableArray *data2 =[[NSMutableArray alloc] init];
        NSMutableArray *data3 =[[NSMutableArray alloc] init];
        
        
        NSMutableArray *category =[[NSMutableArray alloc] init];
        NSArray *closeYesterday = responseObject[@"yestclose"];//昨日收盘价
        NSMutableArray *array =responseObject[@"data"];
        
        for (int i = 0; i < array.count; i ++) {
            NSArray *ziArray =array[i];
            [category addObject:ziArray[0]];
            NSArray *item1 = @[ziArray[2],closeYesterday]; //均价
            NSArray *item2 = @[ziArray[1],closeYesterday]; //实时价格
            
            NSString *volume = [NSString stringWithFormat:@"%d",[ziArray[3] intValue]/100]; //成交量
            NSArray *item3 = @[volume,ziArray[1],closeYesterday];
            
            [data1 addObject:item1];
            [data2 addObject:item2];
            [data3 addObject:item3];
            
            NSLog(@"item = %@%@%@",item1,item2,item3);
        }
        [self renderChart:responseObject];
        //上面构造数据的方法，可以按照需求更改；数据源构建完毕后，赋值到分时图上
        [self.fenshiChart appendToData:data1 forName:kFenShiAvgNameLine];
        [self.fenshiChart appendToData:data2 forName:kFenShiNowNameLine];
        [self.fenshiChart appendToData:data3 forName:kFenShiVolNameColumn];
        
        //当被选中时，要显示的数据or文字
        [self.fenshiChart appendToCategory:category forName:kFenShiAvgNameLine];
        [self.fenshiChart appendToCategory:category forName:kFenShiNowNameLine];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}
#pragma  mark K线图数据请求
-(void)loadDataK:(NSString *)url{
    AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
    
    sessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
    sessionManager.responseSerializer = [AFJSONResponseSerializer serializer];
    sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/x-javascript", @"text/html",nil];
    // 设置访问超时时间 （系统默认是60）
    sessionManager.requestSerializer.timeoutInterval = 30;
    
    NSMutableArray * array = [NSMutableArray array];
    
    [sessionManager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSMutableArray *arrrayD =responseObject;
        NSLog(@"%@",responseObject);
        for (int i=0; i< arrrayD.count; i++) {
              NSDictionary *dic =arrrayD[i];
            YKLineEntity * entity = [[YKLineEntity alloc]init];
            entity.high = [dic[@"High"] doubleValue];
            entity.open = [dic[@"Open"] doubleValue];
            
            entity.low = [dic[@"Low"] doubleValue];
            
            entity.close = [dic[@"Close"] doubleValue];
            
            entity.date = dic[@"DateStr"];
            
            
            double sumClose5 = 0;
            for (int j=0+i; j<MA5 + i  && i+MA5<arrrayD.count; j++) {//MA5
                NSDictionary *dic2 =arrrayD[j];
                sumClose5+= [dic2[@"Close"] doubleValue];
            }
            
            entity.ma5 = sumClose5/MA5;
            
            double sumClose10 = 0;
            for (int j=0+i; j<MA10 + i  && i+MA10<arrrayD.count; j++) {//MA5
                NSDictionary *dic2 =arrrayD[j];
                sumClose10 += [dic2[@"Close"] doubleValue];
            }
            
            entity.ma10 = sumClose10/MA10;

            double sumClose20 = 0;
            for (int j=0+i; j<MA20 + i  && i+MA20<arrrayD.count; j++) {//MA5
                NSDictionary *dic2 =arrrayD[j];
                sumClose20 += [dic2[@"Close"] doubleValue];
            }
            
            entity.ma20 = sumClose20/MA20;

            
           // entity.ma5 = [dic[@"avg5"] doubleValue];
           // entity.ma10 = [dic[@"avg10"] doubleValue];
           // entity.ma20 = [dic[@"avg20"] doubleValue];
            
            entity.volume = [dic[@"Vol"] doubleValue];
            [array addObject:entity];
            
        }
        [array addObjectsFromArray:array];
        YKLineDataSet * dataset = [[YKLineDataSet alloc]init];
        dataset.data = array;
        dataset.highlightLineColor = [UIColor colorWithRed:60/255.0 green:76/255.0 blue:109/255.0 alpha:1.0];
        dataset.highlightLineWidth = 0.7;
        dataset.candleRiseColor = [UIColor colorWithRed:233/255.0 green:47/255.0 blue:68/255.0 alpha:1.0];
        dataset.candleFallColor = [UIColor colorWithRed:33/255.0 green:179/255.0 blue:77/255.0 alpha:1.0];
        dataset.avgLineWidth = 1.f;
        dataset.avgMA10Color = [UIColor colorWithRed:252/255.0 green:85/255.0 blue:198/255.0 alpha:1.0];
        dataset.avgMA5Color = [UIColor colorWithRed:67/255.0 green:85/255.0 blue:109/255.0 alpha:1.0];
        dataset.avgMA20Color = [UIColor colorWithRed:216/255.0 green:192/255.0 blue:44/255.0 alpha:1.0];
        dataset.candleTopBottmLineWidth = 1;
        // 位置
        //[self.klineView setupChartOffsetWithLeft:0 top:40 right:50 bottom:10];
        
         self.klineView = [[YKLineChartView alloc] init];
        
        self.klineView.frame = CGRectMake(0, 40, SCREEN_WIDTH , 240);
        
        [self.FenKview addSubview:_klineView];
        
        self.klineView.gridBackgroundColor = [UIColor whiteColor];
        self.klineView.borderColor = [UIColor colorWithRed:203/255.0 green:215/255.0 blue:224/255.0 alpha:1.0];
        self.klineView.borderWidth = .5;
        self.klineView.candleWidth = 8;
        self.klineView.candleMaxWidth = 30;
        self.klineView.candleMinWidth = 1;
        self.klineView.uperChartHeightScale = 0.7;
        self.klineView.xAxisHeitht = 25;
        self.klineView.delegate = self;
        self.klineView.highlightLineShowEnabled = YES;
        self.klineView.zoomEnabled = YES;
        self.klineView.scrollEnabled = YES;
        [self.klineView setupData:dataset];
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];

    
}
/**
 *  初始化分时图
 */
-(void)initFenShiChart{
    
    NSMutableArray *padding = [NSMutableArray arrayWithObjects:@"0",@"0",@"20",@"5",nil];
    [self.fenshiChart setPadding:padding]; //设置内边距
    NSMutableArray *secs = [[NSMutableArray alloc] init];
    [secs addObject:@"2"]; //设置上下两部分比例
    [secs addObject:@"1"];
    
    [self.fenshiChart addSections:2 withRatios:secs];
    [[[self.fenshiChart sections] objectAtIndex:0] addYAxis:0];
    [[[self.fenshiChart sections] objectAtIndex:1] addYAxis:0];
    
    [self.fenshiChart getYAxis:0 withIndex:0].tickInterval = 4; //设置虚线数量
    [self.fenshiChart getYAxis:1 withIndex:0].tickInterval = 2;
    self.fenshiChart.range = 280; //设置显示区间大小
    
    NSMutableArray *series = [[NSMutableArray alloc] init];
    
    NSMutableArray *secOne = [[NSMutableArray alloc] init];
    NSMutableArray *secTwo = [[NSMutableArray alloc] init];
    
    //均价
    NSMutableDictionary *serie = [[NSMutableDictionary alloc] init];
    NSMutableArray *data = [[NSMutableArray alloc] init];
    [serie setObject:kFenShiAvgNameLine forKey:@"name"]; //用于标记线段名称
    [serie setObject:@"均价" forKey:@"label"]; //当选中时，Label 要显示的名称
    [serie setObject:data forKey:@"data"]; //均线数据 （当获取到实时数据后，就是对此字段赋值；然后实时刷新UI）
    [serie setObject:kFenShiLine forKey:@"type"]; //标记当前绘图类型
    [serie setObject:@"0" forKey:@"yAxisType"]; //标记当前Y轴类型
    [serie setObject:@"0" forKey:@"section"]; //标记当前所属部分
    [serie setObject:kFenShiAvgColor forKey:@"color"]; //均价线段的颜色
    [series addObject:serie];
    [secOne addObject:serie];
    
    
    //实时价
    serie = [[NSMutableDictionary alloc] init];
    data = [[NSMutableArray alloc] init];
    [serie setObject:kFenShiNowNameLine forKey:@"name"];
    [serie setObject:@"数值" forKey:@"label"];
    [serie setObject:data forKey:@"data"];
    [serie setObject:kFenShiLine forKey:@"type"];
    [serie setObject:@"1" forKey:@"yAxisType"];
    [serie setObject:@"0" forKey:@"section"];
    [serie setObject:kFenShiNowColor forKey:@"color"];
    [series addObject:serie];
    [secOne addObject:serie];
    
    //VOL
    serie = [[NSMutableDictionary alloc] init];
    data = [[NSMutableArray alloc] init];
    [serie setObject:kFenShiVolNameColumn forKey:@"name"];
    [serie setObject:@"量" forKey:@"label"];
    [serie setObject:data forKey:@"data"];
    [serie setObject:kFenShiColumn forKey:@"type"];
    [serie setObject:@"1" forKey:@"section"];
    [serie setObject:@"0" forKey:@"decimal"]; //保留几位小数
    [series addObject:serie];
    [secTwo addObject:serie];
    [self.fenshiChart setSeries:series];
    [[[self.fenshiChart sections] objectAtIndex:0] setSeries:secOne];
    [[[self.fenshiChart sections] objectAtIndex:1] setSeries:secTwo];
    
}

-(void)setOptions:(NSDictionary *)options ForSerie:(NSMutableDictionary *)serie;{
    [serie setObject:[options objectForKey:@"name"] forKey:@"name"];
    [serie setObject:[options objectForKey:@"label"] forKey:@"label"];
    [serie setObject:[options objectForKey:@"type"] forKey:@"type"];
    [serie setObject:[options objectForKey:@"yAxis"] forKey:@"yAxis"];
    [serie setObject:[options objectForKey:@"section"] forKey:@"section"];
    [serie setObject:[options objectForKey:@"color"] forKey:@"color"];
}


/**
 *  配置数据源，生成分时图
 *
 *  @param responseObject 数据参数
 */
- (void)renderChart:(NSDictionary *)responseObject{
    
    [self.fenshiChart reset];
    [self.fenshiChart clearData];
    [self.fenshiChart clearCategory];
    //重绘图表
    [self.fenshiChart setNeedsDisplay];
    
}
// 底部的view视图
-(void)setUIView{
    
    self.bottomView =[[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT- 40, SCREEN_WIDTH, 40)];
    
    self.bottomView.backgroundColor = [UIColor grayColor];
    self.bottomView.alpha = 0.95;
    UIView *leftView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/ 5 *2, 40)];
    leftView.backgroundColor =[UIColor redColor];
    UIImageView *immageView =[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20 , 20)];
    [immageView setImage:[UIImage imageNamed:@"message_off"]];
    
//    UILabel *pinglinLabel =[[UILabel alloc]initWithFrame:CGRectMake(35, 0, SCREEN_WIDTH/5, 40)];
//    pinglinLabel.text = @"12条评论";
//    pinglinLabel.textAlignment = NSTextAlignmentCenter;
    UIButton *commentBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    commentBtn.frame = CGRectMake(35, 0, SCREEN_WIDTH/5, 40);
    [commentBtn setTitle:@"12条评论" forState:UIControlStateNormal];
    [commentBtn addTarget:self action:@selector(comment:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [leftView addSubview:commentBtn];
    [leftView addSubview:immageView];
    
    UILabel *zixuanLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH / 5 *2, 0, SCREEN_WIDTH/ 5, 40)];
    
    zixuanLabel.text = @"+ 自选";
    zixuanLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel *buyLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 5 *3, 0, SCREEN_WIDTH /5, 40)];
    
    buyLabel.text = @"买入";
    buyLabel.textAlignment = NSTextAlignmentCenter;
    
    UILabel *fenxiangLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 5 *4, 0, SCREEN_WIDTH/5, 40)];
    
    fenxiangLabel.text = @"分享";
    fenxiangLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.bottomView addSubview:fenxiangLabel];
    
    [self.bottomView addSubview:buyLabel];
    
    [self.bottomView addSubview:zixuanLabel];
    
    [self.bottomView addSubview:leftView];
    
    //[[UIApplication sharedApplication].delegate window];
    
    [self.view addSubview:self.bottomView];
    
}
-(void)comment:(UIButton *)sender{
    
    CommentController *commentVC =[[CommentController alloc]init];
    
    [self presentViewController:commentVC animated:YES completion:nil];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setUIView];
    
   /*
    NSString *strdata = [GetStockLastData stringByAppendingString:[self stringDo:_nameStr]];
    
    NSLog(@"%@",strdata);
    
    [NetWorkManager getUrl1:strdata paramdic:nil success:^(id data) {
        
        NSStringEncoding enc =CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
        
        NSString *str = [[NSString alloc] initWithData:data encoding:enc];
        
        NSMutableArray *bigArray = [str componentsSeparatedByString:@";"].mutableCopy;
        [bigArray removeLastObject];
        
        NSMutableArray *nameArray = [NSMutableArray array];
        NSMutableArray *dataArray = [NSMutableArray array];
        for (NSString *s in bigArray) {
            NSString *dataStr = [[s componentsSeparatedByString:@"=\""].lastObject substringToIndex:[s componentsSeparatedByString:@"=\""].lastObject.length - 1];
            [nameArray addObject:[dataStr componentsSeparatedByString:@","].firstObject];
            NSMutableArray *da = [dataStr componentsSeparatedByString:@","].mutableCopy;
            if (da.count > 0) {
                [da removeObjectAtIndex:0];
            }
            [dataArray addObject:da];
        }
        for (int i = 0; i < nameArray.count; i++) {
            NSDictionary *dict = @{
                                   @"name":nameArray[i],
                                   @"values":dataArray[i],
                                   };
            [self.dataArray addObject:dict];
        }
        NSLog(@"%@",self.dataArray);
        //[self hahahaha];
        
        
    } error:^(id error) {
        NSLog(@"%@",error);
        
    }];
*/
    self.view.backgroundColor = [UIColor whiteColor];
    self.navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 84)];
    _navView.backgroundColor = [UIColor redColor];
    
    self.leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    _leftBtn.frame= CGRectMake(10, 30, 30, 30) ;
    [_leftBtn addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
   
    
    self.goBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    _goBtn.frame = CGRectMake(SCREEN_WIDTH / 2- 80, 30, 30, 30) ;
    [_goBtn setImage:[UIImage imageNamed:@"pre"] forState:UIControlStateNormal];
    [_goBtn addTarget:self action:@selector(gobtn:) forControlEvents:UIControlEventTouchUpInside];
/*
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 2 -50, 30, 100, 30)];
    
    //_nameLabel.text = self.da;
    
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.textColor = [UIColor whiteColor];
    
    
    if (self.incomeArray != nil) {
        
        _incomeModel = self.incomeArray[_index];
        
        NSLog(@"asaaasdaffcc1223%@",_incomeModel.Name);
        _nameLabel.text = _incomeModel.Name;
        NSLog(@"asaaasdaffcc1223%@",_nameLabel.text);
    }
    
    if (self.rankArray !=nil) {
        
        _rankModel = self.rankArray[_index];
        _nameLabel.text = _rankModel.Name;
        
    }
  */
    
    [self dataNameLabel];
    [self netData];
    
   //  [self StrCode];
    self.backBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    _backBtn.frame = CGRectMake(SCREEN_WIDTH / 2 + 50, 30, 30, 30) ;
    [_backBtn setImage:[UIImage imageNamed:@"next"] forState:UIControlStateNormal];
    [_backBtn addTarget:self action:@selector(backBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _rightBtn.frame = CGRectMake(SCREEN_WIDTH - 50, 30, 30, 30);
    [_rightBtn setImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
    [_rightBtn addTarget:self action:@selector(seachBtn:) forControlEvents:UIControlEventTouchUpInside];

    [_navView addSubview:_leftBtn];
    [_navView addSubview:_goBtn];
    [_navView addSubview:_nameLabel];
    [_navView addSubview:_backBtn];
    [_navView addSubview:_rightBtn];
    [self.view addSubview:_navView];
    
    
    self.scrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(0, 84, SCREEN_WIDTH, 1000)];
    _scrollView.backgroundColor = [UIColor cyanColor];
    _scrollView.delegate = self;
    //_scrollView.pagingEnabled = YES;
    _scrollView.contentSize = CGSizeMake(0, 2000);
    _scrollView.bounces = NO;
    
    [self.view addSubview:_scrollView];
    
    [self.view bringSubviewToFront:self.bottomView];
    
    
    
    self.headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    _headView.backgroundColor = [UIColor whiteColor];

    [_scrollView addSubview:_headView];
    
    // 加载头部视图
     [self setTopView];
/*
//     self.FKView = [[CPSpinnerButtonView alloc] initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH  , 350)];
//    _FKView.tintColor = [UIColor whiteColor];
//    _FKView.minGap = 50;
//    _FKView.lineHeight = 2;
//    _FKView.delegate = self;
//    _FKView.selectColor = [UIColor redColor];
//    _FKView.unSelectColor = [UIColor blackColor];
//    UIView *view1 = [UIView new];
//    view1.backgroundColor = [UIColor cyanColor];
//    UIView *view2 =[UIView new];
//    view2.backgroundColor =[UIColor blueColor];
//    UIView *view3 =[UIView new];
//    view3.backgroundColor = [UIColor grayColor];
//    UIView *view4 =[UIView new];
//    view4.backgroundColor =[UIColor blackColor];
    
    
//    [_FKView addContentItems:@[view1, view2,view3,view4] Titles:@[@"分时", @"日K",@"周K",@"月k"]];
//    
//    self.dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(1, 435, SCREEN_WIDTH/3-2, 30)];
//    _dataLabel.text = @"日期";
//    _dataLabel.textAlignment = NSTextAlignmentCenter;
//    _dataLabel.layer.borderWidth = 0.3;
//    _dataLabel.backgroundColor = [UIColor whiteColor];
//    self.liangLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/3 +1 , 435, SCREEN_WIDTH /3-2, 30)];
//    _liangLabel.text = @"量化指数";
//    _liangLabel.textAlignment = NSTextAlignmentCenter;
//    _liangLabel.layer.borderWidth = 0.3;
//     _liangLabel.backgroundColor = [UIColor whiteColor];
//    self.jianyiLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /3 *2 + 2  , 435, SCREEN_WIDTH /3-4, 30)];
//    _jianyiLabel.text = @"投资建议";
//    _jianyiLabel.textAlignment = NSTextAlignmentCenter;
//    _jianyiLabel.layer.borderWidth = 0.3;
//     _jianyiLabel.backgroundColor = [UIColor whiteColor];
//    
//    [_scrollView addSubview:_dataLabel];
//    [_scrollView addSubview:_liangLabel];
//    [_scrollView addSubview:_jianyiLabel];
//    [_scrollView addSubview:_headView];
//    [_scrollView addSubview:_FKView];
 */
    
    self.FenKview =[[UIView alloc]initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH  , 280)];
    _FenKview.backgroundColor =[UIColor grayColor];
    
    self.Fenview =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240)];
    [self.FenKview  addSubview:_Fenview];
    self.TopView = [[LiuXSegmentView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 10, 40) titles:@[@"分时",@"日K",@"周K",@"月K"] clickBlick:^(NSInteger index) {
        if (index == 1) {
           
            self.fenshiChart = [[EverChart alloc] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH / 5 *4 , 240)];
            [self.Fenview addSubview:self.fenshiChart];
            
            NSString *str = @"http://robin.iok.la/LHWeb/Api/GetStockMinData?code=";
            NSString *str2 = [str stringByAppendingString:self.codeStr];
            [self loadDate:str2];
            
            [self initFenShiChart];
            [self.FenKview addSubview:_Fenview];
            [self.Fenview addSubview:self.rightView];
            
        }
        if (index == 2) {
            
            
          NSString *baseStr = @"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=%@&staDate=%@&endDate=%@&type=%@";
            NSString * code = self.codeStr;
            NSString *startDate = @"2015-1-1";
            NSString *endDate = @"2016-1-1";
            NSString *type = @"1";
            
              NSString *url = [[NSString alloc] initWithFormat:baseStr, code, startDate, endDate, type];
//            NSString *str = [baseStr stringByAppendingFormat:@"%@",self.codeStr];
            NSLog(@"%@",url);
           //[self loadDataK:@"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=002709.SZ&staDate=2015-1-1&endDate=2016-5-29&type=1"];
            [self loadDataK:url];
            //[self.FenKview addSubview:_klineView];
            [self.rightView removeFromSuperview];

            
        }
        if (index == 3) {
            NSString *baseStr = @"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=%@&staDate=%@&endDate=%@&type=%@";
            NSString * code = self.codeStr;
            NSString *startDate = @"2015-1-1";
            NSString *endDate = @"2016-1-1";
            NSString *type = @"7";
            
            NSString *url = [[NSString alloc] initWithFormat:baseStr, code, startDate, endDate, type];
            //            NSString *str = [baseStr stringByAppendingFormat:@"%@",self.codeStr];
            NSLog(@"%@",url);
            //[self loadDataK:@"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=002709.SZ&staDate=2015-1-1&endDate=2016-5-29&type=1"];
            [self loadDataK:url];
            //[self.FenKview addSubview:_klineView];
            [self.rightView removeFromSuperview];

        }
        if (index == 4) {
            
            NSString *baseStr = @"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=%@&staDate=%@&endDate=%@&type=%@";
            NSString * code = self.codeStr;
            NSString *startDate = @"2015-1-1";
            NSString *endDate = @"2016-1-1";
            NSString *type = @"1";
            
            NSString *url = [[NSString alloc] initWithFormat:baseStr, code, startDate, endDate, type];
            //            NSString *str = [baseStr stringByAppendingFormat:@"%@",self.codeStr];
            NSLog(@"%@",url);
            //[self loadDataK:@"http://abiao123.xicp.net/LHWeb/Api/GetKLineData?code=002709.SZ&staDate=2015-1-1&endDate=2016-5-29&type=1"];
            [self loadDataK:url];
            //[self.FenKview addSubview:_klineView];
            [self.rightView removeFromSuperview];


       }
        
        
        
    }];
    self.TopView.block(1);
   self.rightView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH / 5 * 4, 40, SCREEN_WIDTH / 5, 240)];
    
    _rightView.backgroundColor =[UIColor whiteColor];
    
    UILabel * sell5 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/15, 20)];
    sell5.text = @"卖5";
    sell5.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell51 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15, 0, SCREEN_WIDTH/15, 20)];
    self.sell51 = sell51;
    sell51.text = @"15.82";
    sell51.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell52 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 0, SCREEN_WIDTH/15, 20)];
    sell52.text = @"710";
    self.sell52 = sell52;
    sell52.textAlignment = NSTextAlignmentLeft;
    sell52.font =[UIFont systemFontOfSize:10];
    
    
    
    
    UILabel * sell4 = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH/15, 20)];
    sell4.text = @"卖4";
    
    sell4.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell41 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 , 20, SCREEN_WIDTH/15, 20)];
    sell41.text = @"14.82";
    self.sell41 = sell41;
    sell41.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell42 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 20, SCREEN_WIDTH/15, 20)];
    sell42.text = @"740";
    self.sell42 = sell42;
    sell42.textAlignment = NSTextAlignmentLeft;
    sell42.font =[UIFont systemFontOfSize:10];
    
    
    UILabel * sell3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH/15, 20)];
    sell3.text = @"卖3";
    
    sell3.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell31 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15, 40, SCREEN_WIDTH/15, 20)];
    sell31.text = @"16.82";
    self.sell31  = sell31;
    sell31.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell32 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 40, SCREEN_WIDTH/12, 20)];
    self.sell32 = sell32;
    sell32.text = @"60";
    sell32.textAlignment = NSTextAlignmentLeft;
    sell32.font =[UIFont systemFontOfSize:10];
    
    
    UILabel * sell2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH/15, 20)];
    sell2.text = @"卖2";
    sell2.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell21 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 , 60, SCREEN_WIDTH/15, 20)];
    sell21.text = @"16.82";
    self.sell21 = sell21;
    sell21.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell22 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 60, SCREEN_WIDTH/15, 20)];
    sell22.text = @"640";
    self.sell22 = sell22;
    sell22.textAlignment = NSTextAlignmentLeft;
    sell22.font =[UIFont systemFontOfSize:10];
    
    
    UILabel * sell1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH/15, 20)];
    sell1.text = @"卖1";
    sell1.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell11 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15, 80, SCREEN_WIDTH/15, 20)];
    sell11.text = @"13";
    self.sell11 = sell11;
    sell11.font =[UIFont systemFontOfSize:10];
    
    UILabel * sell12 = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 80, SCREEN_WIDTH/15, 20)];
    sell12.text = @"120";
    self.sell12 = sell12;
    sell12.textAlignment = NSTextAlignmentLeft;
    sell12.font =[UIFont systemFontOfSize:10];
    
    
    
    UIView *lineView =[[UIView alloc]initWithFrame:CGRectMake(0, 105, SCREEN_WIDTH / 4, 1)];
    lineView.backgroundColor = [UIColor grayColor];
    
    
    
    UILabel *buy1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 110, SCREEN_WIDTH/15, 20)];
    buy1.text = @"买1";
    
    buy1.font =[UIFont systemFontOfSize:10];
    
    
    UILabel *buy11 =[[UILabel alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/15, 110, SCREEN_WIDTH/15, 20)];
    buy11.text = @"34.12";
    self.buy11 = buy11;
    buy11.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy12 =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 110, SCREEN_WIDTH/15, 20)];
    buy12.text = @"1231";
    self.buy12 = buy12;
    buy12.textAlignment = NSTextAlignmentLeft;
    buy12.font =[UIFont systemFontOfSize:10];
    
    
    UILabel *buy2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 130, SCREEN_WIDTH/15, 20)];
    buy2.text = @"买2";
    
    buy2.font =[UIFont systemFontOfSize:10];
    
    
    UILabel *buy21 =[[UILabel alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/15, 130, SCREEN_WIDTH/15, 20)];
    buy21.text = @"34.12";
    self.buy21 = buy21;
    buy21.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy22 =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 130, SCREEN_WIDTH/15, 20)];
    buy22.text = @"34";
    self.buy22 = buy22;
    buy22.textAlignment = NSTextAlignmentLeft;
    buy22.font =[UIFont systemFontOfSize:10];
    
    
    
    UILabel *buy3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 150, SCREEN_WIDTH/15, 20)];
    buy3.text = @"买3";
    buy3.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy31 =[[UILabel alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/15, 150, SCREEN_WIDTH/15, 20)];
    buy31.text = @"34.12";
    self.buy31 = buy31;
    buy31.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy32 =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 150, SCREEN_WIDTH/15, 20)];
    buy32.text = @"34";
    self.buy32 = buy32;
    buy32.textAlignment = NSTextAlignmentLeft;
    buy32.font =[UIFont systemFontOfSize:10];
    
    
    UILabel *buy4 = [[UILabel alloc]initWithFrame:CGRectMake(0, 170, SCREEN_WIDTH/15, 20)];
    buy4.text = @"买4";
    buy4.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy41 =[[UILabel alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/15, 170, SCREEN_WIDTH/15, 20)];
    buy41.text = @"34.12";
    self.buy41 = buy41;
    buy41.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy42 =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 170, SCREEN_WIDTH/15, 20)];
    buy42.text = @"34";
    self.buy42 = buy42;
    buy42.textAlignment = NSTextAlignmentLeft;
    buy42.font =[UIFont systemFontOfSize:10];
    
    
    UILabel *buy5 = [[UILabel alloc]initWithFrame:CGRectMake(0, 190, SCREEN_WIDTH/15, 20)];
    buy5.text = @"买5";
    buy5.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy51 =[[UILabel alloc]initWithFrame:CGRectMake( SCREEN_WIDTH/15, 190, SCREEN_WIDTH/15, 20)];
    buy51.text = @"34.12";
    self.buy51 = buy51;
    buy51.font =[UIFont systemFontOfSize:10];
    
    UILabel *buy52 =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/15 *2, 190, SCREEN_WIDTH/15, 20)];
    buy52.text = @"34";
    self.buy52 = buy52;
    buy52.textAlignment = NSTextAlignmentLeft;
    buy52.font =[UIFont systemFontOfSize:10];
    
    UIButton *fiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    fiveBtn.frame = CGRectMake(0,210,SCREEN_WIDTH/10, 30);
    [fiveBtn setTitle:@"五档" forState:UIControlStateNormal];
    fiveBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
    fiveBtn.titleLabel.font =[UIFont systemFontOfSize:12];
    [fiveBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    UIView *lineView1 =[[UIView alloc]initWithFrame:CGRectMake(0, 210, SCREEN_WIDTH/5, 1)];
    lineView1.backgroundColor = [UIColor grayColor];
    
    UIView *lineView2 =[[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/10, 211, 1, 29)];
    lineView2.backgroundColor = [UIColor grayColor];
    
    
    UIButton *detailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    detailBtn.frame = CGRectMake(SCREEN_WIDTH/10 + 1,211,SCREEN_WIDTH/10, 30);
    [detailBtn setTitle:@"明细" forState:UIControlStateNormal];
    detailBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
    detailBtn.titleLabel.font =[UIFont systemFontOfSize:12];
    [detailBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    
    [_rightView addSubview:sell5];
    [_rightView addSubview:sell51];
    [_rightView addSubview:sell52];
    
    [_rightView addSubview:sell4];
    [_rightView addSubview:sell41];
    [_rightView addSubview:sell42];
    
    [_rightView addSubview:sell3];
    [_rightView addSubview:sell31];
    [_rightView addSubview:sell32];
    
    [_rightView addSubview:sell2];
    [_rightView addSubview:sell21];
    [_rightView addSubview:sell22];
    
    [_rightView addSubview:sell1];
    [_rightView addSubview:sell11];
    [_rightView addSubview:sell12];
    
    [_rightView addSubview:lineView];
    
    
    [_rightView addSubview:buy1];
    [_rightView addSubview:buy11];
    [_rightView addSubview:buy12];
    
    
    [_rightView addSubview:buy2];
    [_rightView addSubview:buy21];
    [_rightView addSubview:buy22];
    
    [_rightView addSubview:buy3];
    [_rightView addSubview:buy31];
    [_rightView addSubview:buy32];
    
    [_rightView addSubview:buy4];
    [_rightView addSubview:buy41];
    [_rightView addSubview:buy42];
    
    [_rightView addSubview:buy5];
    [_rightView addSubview:buy51];
    [_rightView addSubview:buy52];
    
    [_rightView addSubview:lineView2];
    [_rightView addSubview:fiveBtn];
    [_rightView addSubview:lineView1];
    [_rightView addSubview:detailBtn];
    
    
    [_TopView addSubview:_rightView];
    
    [_Fenview addSubview:_TopView];
    
    self.FenBorromView =[[UIView alloc]initWithFrame:CGRectMake(0 , 370, SCREEN_WIDTH, 100)];
    _FenBorromView.backgroundColor =[UIColor whiteColor];
    
    UILabel *dataLabel =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/ 3, 30)];
    dataLabel.textAlignment = NSTextAlignmentCenter;
    dataLabel.font =[UIFont systemFontOfSize:15];
    dataLabel.text = @"日期";
    
    UILabel *liangLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 3, 0, SCREEN_WIDTH/ 3, 30)];
    liangLabel.textAlignment = NSTextAlignmentCenter;
    liangLabel.text = @"量化指数";
    liangLabel.font =[UIFont systemFontOfSize:15];
    
    UILabel *jianLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 3 *2, 0, SCREEN_WIDTH/ 3, 30)];
    jianLabel.textAlignment = NSTextAlignmentCenter;
    jianLabel.text = @"投资建议";
    jianLabel.font =[UIFont systemFontOfSize:15];
    
    // 更多量化交易明细上面的数据
    
    UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH / 3, 30)];
    dateLabel.backgroundColor = [UIColor redColor];
    
    UILabel *linghuaLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/3, 30, SCREEN_WIDTH / 3, 30)];
    linghuaLabel.backgroundColor =[UIColor greenColor];
    
    UILabel *adviseLabel  =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/ 3*2, 30, SCREEN_WIDTH /3, 30)];
    adviseLabel.backgroundColor =[UIColor yellowColor];
    
    
    [_FenBorromView addSubview:dateLabel];
    [_FenBorromView addSubview:linghuaLabel];
    [_FenBorromView addSubview:adviseLabel];
    
    
    UIButton * moreBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    moreBtn.frame = CGRectMake(SCREEN_WIDTH /4, 70, SCREEN_WIDTH/2, 30);
    [moreBtn setTitle:@"更多量化明细交易" forState:UIControlStateNormal];
    moreBtn.titleLabel.font =[UIFont systemFontOfSize:15];
    [moreBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [moreBtn addTarget:self action:@selector(moreBtn:) forControlEvents:
     UIControlEventTouchUpInside];
    moreBtn.layer.cornerRadius = 15;
    moreBtn.layer.borderColor = [UIColor redColor].CGColor;
    moreBtn.layer.borderWidth = 1;

    [_FenBorromView addSubview:moreBtn];
    [_FenBorromView addSubview:jianLabel];
    [_FenBorromView addSubview:liangLabel];
    [_FenBorromView addSubview:dataLabel];
    
    
    [_scrollView addSubview:_FenBorromView];
    
    [_scrollView addSubview:_FenKview];
    
    
    self.ZXView =[[UIView alloc]initWithFrame:CGRectMake(0, 480, SCREEN_WIDTH, 300)];
    _ZXView.backgroundColor =[UIColor yellowColor];
    
    
    
//    self.lineChartView =[[LineChartView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH -20, 270)];
//    [self getDataStockTrade];
//    
//    _lineChartView.backgroundColor = [UIColor whiteColor];
    
    /**
     *  在这里显示那个字典
     */
    
    // 量化收益折线图显示
    [self getDataStockTrade];
    
    
/*
     //_lineChartView.dateArray = [NSMutableArray arrayWithObjects:@"2016-4-14",@"2016-4-18",@"2016-4-26",@"2016-4-23",@"2016-4-24", @"2016-4-25", nil];
     //_lineChartView.dateDetailArray = [NSMutableArray arrayWithObjects:@"2016-4-14",@"2016-4-15",@"2016-4-16",@"2016-4-17",@"2016-4-18", @"2016-4-19",@"2016-4-20",@"2016-4-21",@"2016-4-22",@"2016-4-23",@"2016-4-24", @"2016-4-25", nil];
    //_lineChartView.dataDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"0.2",@"2016-4-25", @"0.9",@"2016-4-24", @"0.6",@"2016-4-23", @"0.0",@"2016-4-22", @"0.8",@"2016-4-21",@"0.01",@"2016-4-20",@"0.3",@"2016-4-19",@"0.01",@"2016-4-18",@"0.73",@"2016-4-17",@"0.5",@"2016-4-16",@"0.02",@"2016-4-15",@"0.7",@"2016-4-14", nil];
    
    //_lineChartView.data1Dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"0.3",@"2016-4-25", @"0.9",@"2016-4-24", @"0.5",@"2016-4-23", @"0.1",@"2016-4-22", @"0.2",@"2016-4-21",@"0.9",@"2016-4-20",@"0.05",@"2016-4-19",@"0.02",@"2016-4-18",@"0.03",@"2016-4-17",@"0.04",@"2016-4-16",@"0.02",@"2016-4-15",@"0.8",@"2016-4-14", nil];

//    UILabel *startLable = [[UILabel alloc]initWithFrame:CGRectMake(20, 260, 100, 20)];
//    startLable.font = [UIFont systemFontOfSize:12];
//    //startLable.backgroundColor= [UIColor redColor];
//    startLable.text = @"2016-06-01";
//    
//    UILabel *endLable = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH- 120, 160, 100, 20)];
//    endLable.font =[UIFont systemFontOfSize:12];
//    endLable.textAlignment = NSTextAlignmentRight;
//    endLable.text = @"2016-07-01";
//    [_ZXView addSubview:startLable];
//    [_ZXView addSubview:endLable];
 */
    UILabel *colorLiang =[[UILabel alloc]initWithFrame:CGRectMake(20, 285, 10, 10)];
    colorLiang.backgroundColor = [UIColor redColor];
    
    UILabel *liangcolorLable =[[UILabel alloc]initWithFrame:CGRectMake(30, 280, 50, 20)];
    liangcolorLable.text = @"量化收益";
    liangcolorLable.textAlignment = NSTextAlignmentCenter;
    liangcolorLable.font =[UIFont systemFontOfSize:12];
    
    UILabel *colorhu =[[UILabel alloc]initWithFrame:CGRectMake(90, 285, 10, 10)];
    colorhu.backgroundColor = [UIColor blueColor];
    
    UILabel *huLable =[[UILabel alloc]initWithFrame:CGRectMake(100, 280, 50, 20)];
    huLable.text = @"沪深300";
    huLable.textAlignment = NSTextAlignmentCenter;
    huLable.font =[UIFont systemFontOfSize:12];
    [_ZXView addSubview:huLable];
    [_ZXView addSubview:colorhu];
    [_ZXView addSubview:colorLiang];
    [_ZXView addSubview:liangcolorLable];

    

    [_scrollView addSubview:_ZXView];
    
    self.LastView =[[LiuXSegmentView alloc]initWithFrame:CGRectMake(0, 790, SCREEN_WIDTH, 40) titles:@[@"技术面",@"基本面",@"资金",@"消息"] clickBlick:^(NSInteger index) {
        if (index == 1) {
            
            UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
            self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH,SCREEN_HEIGHT) collectionViewLayout:layout];
            self.collectionView.backgroundColor = [UIColor grayColor];
            self.collectionView .delegate = self;
            self.collectionView.dataSource = self;
            [self.collectionView registerNib:[UINib nibWithNibName:@"LastCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"collectioncell"];
            [self.collectionView reloadData];
            [_LastView addSubview:self.collectionView];
            
            [self dataGetStockQuantifyData];

            
        }
        if (index == 2) {
            UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
            self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:layout];
            self.collectionView.backgroundColor = [UIColor grayColor];
            self.collectionView .delegate = self;
            self.collectionView.dataSource = self;
            [self.collectionView registerNib:[UINib nibWithNibName:@"LastCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"collectioncell"];
            [self.collectionView reloadData];
            [_LastView addSubview:self.collectionView];
            
             [self dataGetStockQuantifyData1];
        }
        if (index == 3) {
            
           [self dataGetStockQuantifyData2];
          

            UIView *view2 =[[UIView alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT)];
            view2.backgroundColor = [UIColor whiteColor];
            self.chartView = [[ChartView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 200)];
            _chartView.backgroundColor = [UIColor yellowColor];

            
            
            
            [view2 addSubview:_chartView];
            self.view2 = view2;
            
            
            UILabel *redLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2, 235, 10, 10)];
            redLabel.backgroundColor =[UIColor redColor];
            UILabel *ruLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 + 20, 230, 50, 20)];
            ruLabel.text = @"净流入";
            ruLabel.font = [UIFont systemFontOfSize:10];
            
            
            UILabel *greenLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 + 60, 235, 10, 10)];
            greenLabel.backgroundColor =[UIColor greenColor];
            UILabel *chuLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 + 80, 230, 50, 20)];
            chuLabel.text = @"净流出";
            chuLabel.font = [UIFont systemFontOfSize:10];
            
            UILabel *danLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 + 120, 230, 100, 20)];
            danLabel.text = @"单位：万元";
            danLabel.font=[UIFont systemFontOfSize:10];
            [view2 addSubview:danLabel];
            [view2 addSubview:ruLabel];
            [view2 addSubview:redLabel];
            [view2 addSubview:chuLabel];
            [view2 addSubview:greenLabel];
            [_LastView addSubview:view2];
        }
        if (index == 4) {
            self.tableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
            [self.tableView registerNib:[UINib nibWithNibName:@"MessageViewCell" bundle:nil] forCellReuseIdentifier:cellfile];
            self.tableView.delegate = self;
            self.tableView.dataSource = self;
            [_LastView addSubview:self.tableView];
            [self dataGetStockQuantifyData3];
        }
        
        NSLog(@"%ld",index);
    }];
    self.LastView.block(1);
    
    [_scrollView addSubview:_LastView];
    
    
}

#pragma  mark UIScrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSLog(@"%f", scrollView.contentOffset.y);
    if (![scrollView isEqual:self.scrollView]) {
        return;
    }
    if (scrollView.contentOffset.y > 790) {
        self.LastView.frame = CGRectMake(0, scrollView.contentOffset.y, SCREEN_WIDTH, SCREEN_HEIGHT *2);
    }
    if (scrollView.contentOffset.y < 80) {
        
    
        self.LastView.frame = CGRectMake(0, 790, SCREEN_WIDTH, 40);
    }
}


#pragma mark  UICollectionViewDelegate UICollectionViewDataSource UICollectionViewDelegateFlowLayout


//定义每个UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((SCREEN_WIDTH - 4)/3, 100);
}

//定义每个UICollectionView 的 margin
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(1, 1, 1, 1);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    
    return 1;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 1;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.techArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    LastCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellindefiler forIndexPath:indexPath];
    
    cell.model = self.techArray[indexPath.row];
    
    cell.descrLabel.layer.cornerRadius = 7;
    
    cell.descrLabel.layer.borderWidth = 1;
    
    return cell;
}



#pragma mark  UITableViewDelegate,UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  self.messageArray.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    MessageViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellfile forIndexPath:indexPath];
    cell.goodLabel.layer.borderWidth = 1;
    cell.goodLabel.layer.cornerRadius = 7;
    cell.model = self.messageArray[indexPath.row];
//    if (cell.titleLabel.width > SCREEN_WIDTH) {
//        cell.titleLabel.width = SCREEN_WIDTH/2;
//    }
    NSLog(@"%@",cell.model);
    return cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}



-(void)moreBtn:(UIButton *)sender{
    NSLog(@"更多量化明细交易");
    
    
}



#pragma mark  CPSpinnerButtonViewDelegate

- (void)buttonView:(CPSpinnerButtonView *)buttonView didSelectItem:(NSNumber*)index{
    NSLog(@"%@-----%@", buttonView, index);
}

#pragma  mark  k线图代理

-(void)chartValueSelected:(YKViewBase *)chartView entry:(id)entry entryIndex:(NSInteger)entryIndex
{
    
}

- (void)chartValueNothingSelected:(YKViewBase *)chartView
{
}

- (void)chartKlineScrollLeft:(YKViewBase *)chartView
{
    
}

// 返回按钮
-(void)back:(UIButton *)sender{
    [self dismissViewControllerAnimated:NO completion:nil];
    
}
// 后退
-(void)gobtn:(UIButton *)sender{
    
    if (self.dataArray.count > 0) {
        [self.dataArray removeAllObjects];
    }
    
    if (_index == 0) {
        _index = 19;
        [self viewDidLoad];
//        [self netData];
    }
    if (_index !=0) {
        _index --;
        [self viewDidLoad];
//        [self netData];

    }
    
    
    NSLog(@"后退");
}
// 前进
-(void)backBtn:(UIButton *)sender{
    if (self.dataArray.count > 0) {
        [self.dataArray removeAllObjects];
    }
    if (_index == 19) {
        _index =0;
        [self viewDidLoad];
//        [self netData];

    }
    if (_index !=19) {
        _index ++;
        [self viewDidLoad];
//        [self netData];

    }
}
// 搜索
-(void)seachBtn:(UIButton *)sender{
    
//    SeachViewController *seachVC=[[SeachViewController alloc]init];
//    
//    [self presentViewController:seachVC animated:YES completion:nil];
    
    NSLog(@"搜索");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 懒加载
- (NSMutableArray *)dataArray{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
